package com.ht.api.call.func.impl.fan;

import cn.hutool.json.JSONObject;
import com.ht.api.bean.AjaxResult;
import com.ht.api.bean.LoginBean;
import com.ht.api.call.func.IFunctionCall;
import com.ht.api.db.Db;
import com.ht.api.db.Entity;
import com.ht.api.db.exception.HtException;

/**
 * 渠道删除前置函数
 */
public class FanChannelDelBeforeFunctionCall implements IFunctionCall{

	@Override
	public String getName() {
		return "渠道删除前置函数";
	}

	@Override
	public JSONObject execute(LoginBean me, JSONObject param, AjaxResult result) {
		long count = Db.createSqlParser("position_channel").where("channel_id", param.getStr("main_id")).count(me.getDataSource());
		if (count > 0) {
			throw new HtException("已有广告位，不能删除渠道！");
		}

		return null;
	}

}
